// 订单表 李鹤
const mongoose = require("./mongoose")
var moment = require('moment')
let Schema = mongoose.Schema;
let orderSchema = new Schema({
    // 顾客id
    userid: String,
    // 商户id
    commercialid:String,
    // 商户名（跟注册时生成的userid相对应，要自行修改成和注册时生成的userid相同的值）
    commercialname:String,
    // 购买的商品
    shop:Array,
    // 订单总价
    price:Number,
    // 生成订单的时间
    createat:String,
});

orderModel = mongoose.model("order",orderSchema);

// orderModel.create([
//     {userid: "1", commercialid: "1", shop:[{shopid:1,name:"西瓜",num:2,price:22},{shopid:2,name:"可乐",num:2,price:6}],price:55,createat:moment(new Date()).format('YYYY-MM-DD')},
//     {userid: "2", commercialid: "2", shop:[{shopid:1,name:"土豆",num:2,price:12},{shopid:3,name:"猪头肉",num:1,price:52}],price:155,createat:moment(new Date()).format('YYYY-MM-DD')},
//     {userid: "3", commercialid: "1", shop:[{shopid:3,name:"西红柿",num:2,price:11},{shopid:4,name:"西蓝花",num:1,price:32}],price:255,createat:moment(new Date()).format('YYYY-MM-DD')},
//     {userid: "3", commercialid: "3", shop:[{shopid:3,name:"羊肉",num:2,price:82},{shopid:4,name:"洋葱",num:1,price:22},{shopid:4,name:"孜然",num:1,price:20}],price:355,createat:moment(new Date()).format('YYYY-MM-DD')},
//     {userid: "4", commercialid: "2", shop:[{shopid:3,name:"香菇",num:2,price:33},{shopid:4,name:"胡萝卜",num:1,price:29},{shopid:1,name:"红牛",num:2,price:6}],price:555,createat:moment(new Date()).format('YYYY-MM-DD')},
// ], (err) => {
//     if(!err) {
//         console.log('插入成功')
//     } else {
//         throw err;
//     }
// })
module.exports = orderModel